﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Feicui.BeautyCRM.IDAL
{
    /// <summary>
    /// 增删改查基类接口
    /// </summary>
    public interface IBaseDal<T> where T : new()
    {

        #region  查询
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="wherelambda"></param>
        /// <returns></returns>
        IQueryable<T> QueryEntitys(Expression<Func<T, bool>> wherelambda);

        /// <summary>
        /// 分页
        /// </summary>
        /// <typeparam name="S"></typeparam>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="totle"></param>
        /// <param name="wherelambda"></param>
        /// <param name="ordlambda"></param>
        /// <param name="isAsc"></param>
        /// <returns></returns>
        IQueryable<T> QueryPageEntitys<S>(int pageSize, int pageIndex, out int totle, Expression<Func<T, bool>> wherelambda, Expression<Func<T, S>> ordlambda, bool isAsc = true);

        #endregion

        #region  添加

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        T AddEntity(T entity);

        #endregion

        #region  修改

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool EditEntity(T entity);

        #endregion

        #region  删除 

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool DelEntity(T entity);

        #endregion
    }
}
